<template>
	<view class="Service">
		<!-- 标题 -->
		<view class="Service-title">
			<view class="Service-title-span"></view>
			<text>我的服务</text>
		</view>
		<!-- 内容 -->
		<view class="Service-main">
			<template v-for="item in ServiceList">
				<view v-if="item.id==4" @click="ddd" class="Service-main-list" :key="item.id">
					<view class="">
						<image class="icon" :src="item.icon" mode=""></image>
						<text>{{item.text}}</text>
					</view>
					<view class="">
						<image class="icon-right" :src="item.icon_right" mode=""></image>
					</view>
				</view>
				<!--  -->
				<view v-else class="Service-main-list" :key="item.id">
					<view class="">
						<image class="icon" :src="item.icon" mode=""></image>
						<text>{{item.text}}</text>
					</view>
					<view class="">
						<image class="icon-right" :src="item.icon_right" mode=""></image>
					</view>
				</view>
			</template>
		</view>
		<!-- 弹出层 -->
		<uni-popup ref="popup" type="bottom">
			<view class="UpdatePassword">
				<!--  -->
				<view class="UpdatePassword-originalPassword">
					<view class="">
						<text>用户名:</text>
					</view>
					<view class="">
						<input v-model="username" disabled type="text" value="" />
					</view>
				</view>
				<view class="UpdatePassword-NewPassword">
					<view class="">
						<text>新密码:</text>
					</view>
					<view class="">
						<input v-model="password" type="text" value="" />
					</view>
				</view>
				<view class="UpdatePassword-btn">
					<button type="default" @click="confirm">确定更改</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>
  
<script>
	export default {
		data() {
			return {
				ServiceList: [{
						icon: "../../../static/mine/user.png",
						text: "实名认证",
						icon_right: "../../../static/mine/right.png",
						id: 1
					},
					{
						icon: "../../../static/mine/icon1.png",
						text: "安全服务",
						icon_right: "../../../static/mine/right.png",
						id: 2
					},
					{
						icon: "../../../static/mine/icon2.png",
						text: "信用评分",
						icon_right: "../../../static/mine/right.png",
						id: 3
					},
					{
						icon: "../../../static/mine/icon3.png",
						text: "隐私设置",
						icon_right: "../../../static/mine/right.png",
						id: 4
					},
					{
						icon: "../../../static/mine/icon4.png",
						text: "辅助功能",
						icon_right: "../../../static/mine/right.png",
						id: 5
					},
					{
						icon: "../../../static/mine/icon5.png",
						text: "帮助反馈",
						icon_right: "../../../static/mine/right.png",
						id: 6
					},
					{
						icon: "../../../static/mine/icon6.png",
						text: "关于",
						icon_right: "../../../static/mine/right.png",
						id: 7
					},
				],
				// 更改用户密码
				username: "", //用户名
				password: "", //密码
			}
		},
		created() {
			const {
				username
			} = getApp().globalData.userInfo
			this.username = username
		},
		methods: {
			ddd() {
				console.log(1)
				this.$refs.popup.open('bottom')
			},
			// 更改密码
			async confirm() {
				if (this.username && this.password) {
					const res = await this.$request({
						url: "/member/updatepsw",
						method: "POST",
						data: {
							username: this.username,
							password: this.password
						}
					})
					if(res.code==200){
						this.$refs.popup.close('bottom');
						uni.showToast({
							title:"修改成功",
							icon:"success"
						})
					}else{
						uni.showToast({
							title:"修改失败",
							icon:"error"
						})
					}
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	@import './Service.scss'
</style>
